﻿using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace WeatherHistory.Data.Migrations
{
    /// <inheritdoc />
    public partial class RegionUpdaterChangedToRegionCreator : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_Regions_Accounts_UpdatedById",
                table: "Regions");

            migrationBuilder.RenameColumn(
                name: "UpdatedById",
                table: "Regions",
                newName: "CreatedById");

            migrationBuilder.RenameIndex(
                name: "IX_Regions_UpdatedById",
                table: "Regions",
                newName: "IX_Regions_CreatedById");

            migrationBuilder.AlterColumn<decimal>(
                name: "Longitude",
                table: "Regions",
                type: "numeric(38,17)",
                nullable: false,
                oldClrType: typeof(decimal),
                oldType: "numeric");

            migrationBuilder.AlterColumn<decimal>(
                name: "Latitude",
                table: "Regions",
                type: "numeric(38,17)",
                nullable: false,
                oldClrType: typeof(decimal),
                oldType: "numeric");

            migrationBuilder.AddForeignKey(
                name: "FK_Regions_Accounts_CreatedById",
                table: "Regions",
                column: "CreatedById",
                principalTable: "Accounts",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_Regions_Accounts_CreatedById",
                table: "Regions");

            migrationBuilder.RenameColumn(
                name: "CreatedById",
                table: "Regions",
                newName: "UpdatedById");

            migrationBuilder.RenameIndex(
                name: "IX_Regions_CreatedById",
                table: "Regions",
                newName: "IX_Regions_UpdatedById");

            migrationBuilder.AlterColumn<decimal>(
                name: "Longitude",
                table: "Regions",
                type: "numeric",
                nullable: false,
                oldClrType: typeof(decimal),
                oldType: "numeric(38,17)");

            migrationBuilder.AlterColumn<decimal>(
                name: "Latitude",
                table: "Regions",
                type: "numeric",
                nullable: false,
                oldClrType: typeof(decimal),
                oldType: "numeric(38,17)");

            migrationBuilder.AddForeignKey(
                name: "FK_Regions_Accounts_UpdatedById",
                table: "Regions",
                column: "UpdatedById",
                principalTable: "Accounts",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }
    }
}
